<?php
ini_set('max_execution_time','0');
ini_set('error_reporting', E_ALL);
$config = array(
        'IN' => 'H:/parse/out',
        'TEMPLATE' => '<div class="breadcrumbs">#breadcrumbs#</div><h2>#title#</h2><div id="content">#description#</div><div id="links">#links#</div>',
        'OUT' => 'H:/parse/res'
);

$content = file_get_contents('H:/parse/out/16.txt');
preg_match('@(<h2>(.*?)<\/h2>)@', $content, $matches );
$title = $matches[2];
print_r($matches);
preg_match('@(class="highslide" onclick="return hs.expand\(this\)" style="float:left; margin: 10px">([\d|\D]*)<tr><td colspan="2"><hr></td></tr></table>)@', $content, $matches);
$description = $matches[2];
// preg_match('@src="([^\"]*)"@', $description, $matches);
// $remoteImgSrc = $matches[1];
//  preg_mat ch('@(.*)\/(.*)\.jpg@' , $remoteImgSrc, $matches);
// $localImageFileName = $matches[2].'.jpg';
// $localImageFile = fopen($outputImagesDir.'/'.$localImageFileName, 'wb');
// echo 'Processing '.$localImageFileName.'<br><br>';
//if($localImageFile) curl_get_image($remoteImgSrc, $localImageFile);
//else echo 'Error maling image copy <br><br>';
preg_match('@(&raquo; <a href="/load/knigi_po_filosofii([^\"]*)">(.*)<\/a>)@',$content, $matches);
$breadcrumbs = $matches[3];
preg_match( '@(<p style="COLOR: #32cd32;" align="center">([\d|\D]*?)<hr>)@', $content, $matches);
$links = $matches[2];
$html = str_replace(array('#breadcrumbs#', '#title#', '#description#', '#links#'), array($breadcrumbs, $title,  $description,  $links),$config['TEMPLATE']);
$html = str_replace('<p class="MsoNormal"><span lang="BG" style="mso-ansi-language:BG"><o:p>&nbsp;</o:p></span></p></td></tr>','', $html);
$html = str_replace(array(' class="MsoNormal"', ' style="mso-bidi-font-weight:normal"', '<span lang="BG" style="mso-ansi-language:BG">', '</span>', '<span lang="BG" style="mso-ansi-language:', 'BG"', '</SPAN>', '/go?','</font>'),array('','','','','','','','',''),$html);


?>